<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title th:text="${category.name}+' - Dark Video'"></title>
    <link th:href="@{/assets/zui/css/zui.min.css}" rel="stylesheet">
</head>
<body>

<!-- 头部 -->
<nav th:replace="common/nav::html"></nav>

<div class="container">
    <!-- 类别导航 -->
    <nav th:replace="common/category_nav::html"></nav>

    <!-- 当前一级类别导航 -->
    <hr>
    <ul class="nav nav-justified nav-pills">
        <li>
            <a th:href="${'/category/'+ firstCategoryId}">全部</a>
        </li>
        <li th:each="secondCategory : ${secondCategories}">
            <a th:href="${'/category/'+ secondCategory.id}" th:text="${secondCategory.name}"></a>
        </li>
    </ul>

    <!-- 主体 -->
    <div class="row">
        <div class="cards cards-borderless">
            <div class="col-md-4 col-sm-6 col-lg-3" th:each="content: ${contents.records}">
                <a class="card" target="_blank" th:href="'/content/'+${content.id}">
                    <img th:src="${content.thumbnail}">
                    <div class="caption" th:if="${content.type=='video'}" th:text="${content.duration}"></div>
                    <div class="card-heading"><strong th:text="${content.name}"></strong></div>
                    <div class="card-actions">
                        <div class="pull-left"><i class="icon-hand-up" th:text="${content.click}"></i></div>
                        <div class="pull-right"><i class="icon-comments-alt" th:text="${content.commentCount}"></i></div>
                    </div>
                </a>
            </div>
        </div>

        <!-- 分页器 -->
        <ul id="myPager" class="pager" data-ride="pager" data-elements=["first","prev","nav","last","next","goto"]
            th:attr="data-page=${contents.current}, data-rec-total=${contents.total}, data-rec-per-page=${contents.size}"></ul>
    </div>
</div>

<script th:src="@{/assets/js/jquery.js}"></script>
<script th:src="@{/assets/js/http.js}"></script>
<script th:src="@{/assets/layer/layer.js}"></script>
<script th:src="@{/assets/zui/js/zui.min.js}"></script>
<script>
    $('#myPager').on('onPageChange', function(e, state, oldState) {
        if(oldState.page != null) {
            if (state.page !== oldState.page) {
                window.location.href = window.location.pathname + '?current=' + state.page;
            }
        }
    });
</script>

</body>
</html>